//
//  Rexel.h
//  Rexel
//
//  Created by Zach Zahos on 2014-05-19.
//  Copyright (c) 2014 Zach Zahos. All rights reserved.
//

#ifndef Rexel_Rexel_h
#define Rexel_Rexel_h

typedef long RXLType;

extern const RXLType RXLTypeEOF;
extern const RXLType RXLTypeUnknown;

typedef enum { RXLFalse, RXLTrue } RXLBool;

typedef enum {
	RXLValidityInvalid = -1,
	RXLValidityIncomplete,
	RXLValidityValid,
	RXLValidityComplete
} RXLValidity;

typedef RXLValidity (*RXLTypeDef)(const char *buffer, unsigned long index, void *settings, void **context);

typedef struct {
	RXLType typeCount;
	unsigned int maxSize;
	RXLTypeDef *typeDefs;
	void **settings;
} RXLTokenizer;

typedef struct {
	const char *buffer;
	unsigned long length, currentStart, currentOffset;
} RXLTokenizeRequest;

typedef struct {
	RXLType type;
	char *token;
	unsigned long length;
} RXLToken;

RXLTokenizer* RXLTokenizerCreate();
RXLType RXLTokenizerAddTypeDef(RXLTokenizer *tokenizer, RXLTypeDef typeDef, void *settings);
RXLTokenizeRequest *RXLTokenizeRequestCreateBuffer(char *buffer, unsigned long length);
RXLToken* RXLTokenizerNextToken(RXLTokenizer *tokenizer, RXLTokenizeRequest *request);

#endif
